const state = {
  products: []
}

const getters = {}
const mutations = {
  getAllProducts(state, payload) {
    state.products = payload
  }
}

const actions = {
  asyncGetAllProducts({commit}) {
    // 调用接口
    const products =  [{
      id: 1,
      title: '小米10',
      price: 200
    },{
      id: 2,
      title: 'HuaWei P10',
      price: 100
    },{
      id: 3,
      title: 'oppo R7',
      price: 1230
    }]

    commit('getAllProducts', products)
  }
}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}